package com.cms.acase.lazyload;

import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.cms.acase.R;

public class SecondFragment extends ModeFragment{

    private boolean isViewCreated = false;



    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater,
                             @Nullable ViewGroup container,
                             @Nullable Bundle savedInstanceState) {
        isViewCreated = true;
        return inflater.inflate(R.layout.fragment_child,container,false);
    }


    @Override
    public void setUserVisibleHint(boolean isVisibleToUser) {
        Log.d("TAG-----", "SecondFragment isVisibleToUser: "+isVisibleToUser);
        super.setUserVisibleHint(isVisibleToUser);
        if (isViewCreated){
            if (isVisibleToUser ){
                disPathVisibleToUser(true);
            }else{
                disPathVisibleToUser(false);
            }
        }

    }
    private void disPathVisibleToUser(boolean isShow) {

        if (isShow){
            startLoadData();
        }else{
            stopLoadData();
        }
    }


    private void startLoadData() {
        Log.d("TAG-----", "SecondFragment startLoadData: ");
    }

    private void stopLoadData() {
        Log.d("TAG-----", "SecondFragment stopLoadData: ");

    }
}
